home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / Asm / Chunky / ChunkyBuffered.s < prev    next >
Encoding:
Text File  |  1997-05-11  |  4.0 KB  |  178 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Chunky Pixel List
  3. ;---------------
  4. ;This demo is like the other pixel list demos but uses a CHUNKY8 screen type.
  5. ;Then screen size has been kept very small as the C2P routine is too slow,
  6. ;but this will be improved in the next version.  The good thing is that
  7. ;because the routine is transparent, using a graphics card would mean that
  8. ;this demo would run at the maximum possible speed.
  9. ;
  10. ;Press LMB to exit.
  11.  
  12.     INCDIR    "INCLUDES:"
  13.     INCLUDE    "games/games_lib.i"
  14.     INCLUDE    "games/games.i"
  15.  
  16. CALL    MACRO
  17.     jsr    _LVO\1(a6)
  18.     ENDM
  19.  
  20.     SECTION    "DrawPixel",CODE
  21.  
  22. ;===========================================================================;
  23. ;                             INITIALISE DEMO
  24. ;===========================================================================;
  25.  
  26.     STARTGMS
  27.  
  28. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  29.     move.l    GMSBase(pc),a6
  30.     CALL    AllocBlitter
  31.     tst.l    d0
  32.     bne.s    .Error_Blitter
  33.  
  34.     lea    ScreenTags(pc),a0
  35.     CALL    ShowScreen
  36.     tst.l    d0
  37.     beq.s    .Error_Screen
  38.  
  39.     CALL    InitJoyPorts
  40.  
  41.     bsr.s    Main
  42.  
  43. .ReturnToDOS
  44.     move.l    GMSBase(pc),a6
  45.     move.l    Screen(pc),a0
  46.     CALL    DeleteScreen
  47. .Error_Screen
  48.     CALL    FreeBlitter
  49. .Error_Blitter
  50.     MOVEM.L    (SP)+,A0-A6/D1-D7
  51.     moveq    #ERR_OK,d0
  52.     rts
  53.  
  54. ;===========================================================================;
  55. ;                                MAIN LOOP
  56. ;===========================================================================;
  57.  
  58. Main:    move.l    Screen(pc),a0
  59.     lea    MList(pc),a2    ;a2 = Pointer to pixel list.
  60. .loop    moveq    #BUFFER2,d0
  61.     CALL    ClrScreen
  62.  
  63.     move.l    a2,a3    ;Drop the pixels here.
  64.     moveq    #31-1,d7
  65. .drop    addq.w    #1,2(a3)    ;a3 = YCoord+1
  66.     subq.l    #1,4(a3)    ;a3 = (Colour)-1
  67.     bge.s    .colok
  68.     clr.l    4(a3)
  69. .colok    addq.w    #8,a3
  70.     dbra    d7,.drop
  71.  
  72.     lea    MouseX(pc),a5
  73.     moveq    #JPORT1,d0
  74.     CALL    ReadMouse
  75.     btst    #MB_LMB,d0
  76.     bne.s    .done
  77.     move.w    d0,d1
  78.     ext.w    d1    ;d1 = Extend the Y byte.
  79.     add.w    d1,2(a5)    ;d1 = (MouseY)+ChangeY
  80.     asr.w    #8,d0    ;d0 = Extend the X byte.
  81.  
  82.     add.w    (a5),d0
  83. .ChkRX    cmp.w    GS_ScrWidth(a0),d0
  84.     blt.s    .ChkLX
  85.     clr.w    (a5)
  86.     bra.s    .Calculate
  87. .ChkLX    tst.w    d0
  88.     bgt.s    .okX
  89.     move.w    GS_ScrWidth(a0),(a5)
  90.     bra.s    .Calculate
  91. .okX    move.w    d0,(a5)
  92.  
  93. .Calculate
  94.     move.l    (a5),-(sp)
  95.     moveq    #2,d1
  96.     CALL    FastRandom
  97.     subq.w    #1,d0
  98.     add.w    d0,(a5)
  99.  
  100.     moveq    #2,d1
  101.     CALL    FastRandom
  102.     subq.w    #1,d0
  103.     add.w    d0,2(a5)
  104.  
  105.     move.l    a2,a3
  106.     moveq    #31-1,d7
  107. .tloop    move.l    8(a3),(a3)
  108.     move.l    12(a3),4(a3)
  109.     addq.w    #8,a3
  110.     dbra    d7,.tloop
  111.  
  112.     lea    PixelList(pc),a1    ;a1 = Pixel list.
  113.     moveq    #BUFFER2,d0    ;d0 = Destination buffer.
  114.     CALL    DrawPixelList    ;>> = Draw pixels with clipping.
  115.  
  116.     move.l    (sp)+,(a5)
  117.     CALL    WaitVBL
  118.     CALL    SwapBuffers
  119.     bra    .loop
  120. .done    rts
  121.  
  122. ;===========================================================================;
  123. ;                                  DATA
  124. ;===========================================================================;
  125.  
  126. ScreenTags:
  127.     dc.l    TAGS_GAMESCREEN
  128. Screen:    dc.l    0
  129.     dc.l    GSA_ScrWidth,128
  130.     dc.l    GSA_ScrHeight,128
  131.     dc.l    GSA_Palette,.palette
  132.     dc.l    GSA_AmtColours,32
  133.     dc.l    GSA_Attrib,DBLBUFFER|CENTRE
  134.     dc.l    GSA_ScrType,CHUNKY8
  135.     dc.l    TAGEND
  136. .palette
  137.     dc.l $000000,$101010,$171717,$202020,$272727,$303030,$373737,$404040
  138.     dc.l $474747,$505050,$575757,$606060,$676767,$707070,$777777,$808080
  139.     dc.l $878787,$909090,$979797,$a0a0a0,$a7a7a7,$b0b0b0,$b7b7b7,$c0c0c0
  140.     dc.l $c7c7c7,$d0d0d0,$d7d7d7,$e0e0e0,$e0e0e0,$f0f0f0,$f7f7f7,$ffffff
  141.  
  142. PixelList:
  143.     dc.w    32,PXL_SIZEOF    ;Amount of entries, EntrySize.
  144.     dc.l    MList    ;Pointer to pixel list array.
  145. MList    PIXEL    16,12,00    ;First pixel to draw (at back)
  146.     PIXEL    16,12,00    ;X/Y/Colour
  147.     PIXEL    16,12,00    ;..
  148.     PIXEL    16,12,00    ;..
  149.     PIXEL    16,12,00    ;..
  150.     PIXEL    16,12,00    ;..
  151.     PIXEL    16,12,00    ;..
  152.     PIXEL    16,12,00    ;..
  153.     PIXEL    16,12,00    ;..
  154.     PIXEL    16,12,00    ;..
  155.     PIXEL    16,12,00    ;..
  156.     PIXEL    16,12,00    ;..
  157.     PIXEL    16,12,00    ;..
  158.     PIXEL    16,12,00    ;..
  159.     PIXEL    16,12,00    ;..
  160.     PIXEL    16,12,00    ;..
  161.     PIXEL    16,12,00    ;..
  162.     PIXEL    16,12,00    ;..
  163.     PIXEL    16,12,00    ;..
  164.     PIXEL    16,12,00    ;..
  165.     PIXEL    16,12,00    ;..
  166.     PIXEL    16,12,00    ;..
  167.     PIXEL    16,12,00    ;..
  168.     PIXEL    16,12,00    ;..
  169.     PIXEL    16,12,00    ;..
  170.     PIXEL    16,12,00    ;..
  171.     PIXEL    16,12,00    ;..
  172.     PIXEL    16,12,00    ;..
  173.     PIXEL    16,12,00    ;..
  174.     PIXEL    16,12,00    ;..
  175.     PIXEL    16,12,00    ;..
  176. MouseX    PIXEL    16,12,31    ;Last pixel to draw (in front)
  177.  
  178.